package edu.sias.controller;

import edu.sias.pojo.S_User;
import edu.sias.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/user/details")
public class UserDetailsServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //获取查询依据
        String name = request.getParameter("name");
        //调用业务层获取相关数据
        UserService userService = new UserService();
        S_User user = userService.findUserInfoByName(name);
        request.setAttribute("user",user);
        //转发请求
        request.getRequestDispatcher("/userDetails.jsp")
                .forward(request,response);

    }
}
